package Junit;

import interfaces.DataRepository;
import junit.framework.TestCase;
import persistence.jdbc.JDBCDataRepository;
import domain.items.Post;

public class WsepConnectionTest extends TestCase {

	private DataRepository _dataRep;
//	private Item _root;
//	private Item _currentlyViewedItem;
	
	public WsepConnectionTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
		this._dataRep = new JDBCDataRepository();
	//	this._root = this._dataRep.getRootTopic();
		//this._currentlyViewedItem = _root;
	}

//	public void testLogin() {
//		assertTrue(connection.login("roee", "123"));
//		//deliberatly want to stumble the login with unknown user!
//		assertFalse(connection.login("adfasdfsf", ""));
//		assertTrue(connection.getUser() instanceof Member);
//	}

	public void testAddPost() {
		Post temp = new Post(null,"o1","s1","c1");
//		connection.setCurrentlyViewedItem(new ForumThread(null));
		_dataRep.addPost(temp);
		assertEquals(_dataRep.getRootTopic().getSubItems().elementAt(0).getName(),"s1");
//		assertFalse(((ForumThread)connection.getCurrentlyViewedItem()).getPosts().get(0).getName().equals("newText"));
//		connection.setCurrentlyViewedItem(temp);
	}

//	public void testUpdatePost() {
//		Item temp = connection.getCurrentlyViewedItem();
//		connection.setCurrentlyViewedItem(new Post(null,null,"subject","bla bla bla bla"));
//		connection.updatePost("newSubject", "newText");
//		assertTrue(((Post)connection.getCurrentlyViewedItem()).getName().equals("newSubject"));
//		assertFalse(((Post)connection.getCurrentlyViewedItem()).getName().equals("newText"));
//		connection.setCurrentlyViewedItem(temp);
//	}
//
//	public void testGetRootTopic() {
//		assertTrue(connection.getRootTopic().getFather() == null);
//	}
//
//	public void testGetCurrentlyViewedItem() {
//		assertTrue(connection.getCurrentlyViewedItem() instanceof Item);
//	}


}
